#include <func.h>

#define MAXPATH 1024

int main(int argc, char* argv[])
{
    // ./t_getcwd 
    // 参数校验
    if (argc != 1) {
        fprintf(stderr, "Usage: %s\n", argv[0]);
        exit(1);
    }

    /* char pathname[MAXPATH]; */
    /* char* ret = getcwd(pathname, MAXPATH); */
    /* if (ret == NULL) { */
    /*     perror("getcwd()"); */
    /*     exit(1); */
    /* } */

    char* pathname = getcwd(NULL, 0);
    if (!pathname) {
        perror("getcwd()");
        exit(1);
    }
    // 调用成功
    puts(pathname);

    // 不要忘记free
    free(pathname);
    return 0;
}

